home *** CD-ROM | disk | FTP | other *** search
/ Utilities Professional 1-1500 / Utilities Professional 1-1500 (1994)(WPD)[!].iso / 12511500 / var1461.dms / var1461.adf / CopperDraw / CopperDraw.doc < prev    next >
Text File  |  1992-05-18  |  21KB  |  616 lines

  1. /***********************************************************/
  2. /*                                                         */
  3. /* Amiga C Encyclopedia (ACE) V3.0      Amiga C Club (ACC) */
  4. /* -------------------------------      ------------------ */
  5. /*                                                         */
  6. /* Book:    ACM Graphics                Amiga C Club       */
  7. /* Chapter: Copper                      Tulevagen 22       */
  8. /* File:    CopperDraw.doc              181 41  LIDINGO    */
  9. /* Author:  Anders Bjerin               SWEDEN             */
  10. /* Date:    92-05-01                                       */
  11. /* Version: 1.00                                           */
  12. /*                                                         */
  13. /*   Copyright 1992, Anders Bjerin - Amiga C Club (ACC)    */
  14. /*                                                         */
  15. /* Registered members may use this program freely in their */
  16. /*     own commercial/noncommercial programs/articles.     */
  17. /*                                                         */
  18. /***********************************************************/
  19.  
  20.  
  21.                I N S T R U C T I O N S
  22.                -----------------------
  23.  
  24.  
  25. 1.0  INTRODUCTION
  26.  
  27. Copper Draw is an extremely useful utility when you want to
  28. create Copper lists. You have at all time full control over
  29. what you are doing and you will immediately see how your
  30. copper list changes as you modify it.
  31.  
  32. Copper Draw was written to be as easy as possible to use, and
  33. is fully amigaized. It can create copper lists for all colour
  34. registers, and when you quit the program will automatically
  35. save the copper list in C code that can be included with your
  36. programs.    
  37.  
  38. CopperDraw is using linked lists and can therefore handle as
  39. many copper instructions as you want. All memory and other
  40. resources are (of course) returned when the program terminates,
  41. and the program follows all "rules".
  42.  
  43. This program is a part of the "Amiga C Encyclopedia", the
  44. largest C collection of information, programs, examples, and
  45. utilities for the Amiga. I have spent more than four years on
  46. writing and improving these manuals, and with your help I can
  47. continue to make then even better. Please register!
  48.  
  49.  
  50.  
  51. 2.0  HOW TO START COPPERDRAW
  52.  
  53. CopperDraw can either be run from the CLI or Workbench. If
  54. it is started from CLI you can specify the name of the file
  55. where the source code for the copper instructions will be
  56. saved. You can also give the copper pointer a name, set the
  57. screen height (values between 95 and 256 are accepted) and
  58. the number of bitplanes that should be used (1 bitplane = 2
  59. colours, 2 bitplanes = 4 colours and so on, up to 5
  60. bitplanes = 32 colours).
  61.  
  62. If CopperDraw is started from Workbench or you have given
  63. the program illegal parameters, the default values will be
  64. used. The default file name is "RAM:Copper.c", pointer name
  65. is "copper", screen height is set to 200, and five bitplanes
  66. are used (32 colours).
  67.  
  68. To start from CLI you write:
  69. CopperDraw <output> <copper name> <number of bitplanes> <screen height>
  70.  
  71. To start CopperDraw with 8 colours (3 bitplanes), 256 pixels
  72. tall display and use the file name "MyFirstCopperList.c", you
  73. would write:
  74.  
  75. To start CopperDraw from Workbench simply double click on
  76. the CopperDraw icon. The default values will be used.
  77.  
  78.  
  79.  
  80. 3.  USE COPPERDRAW
  81.  
  82. When you start CopperDraw the whole screen will be filled with
  83. one large screen. On top of the screen one window is opened.
  84. The window should look something like this:
  85.  
  86.     Quit
  87.     |
  88.     |    Red, Green and Blue sliders
  89.     |    |
  90.   +-|-+--|--------------------------------+
  91.   | v |  |                                |
  92.   +---+--|--------------------------------+
  93.   |   +--|-----------+ +-+                |
  94.   | R |# |           | |0|     COLOUR <----- Current edit mode
  95.   |   +--|-----------+ +-+  +------+ +--+ |
  96.   | G |# v           | |0|  |SPREAD| |EX| |
  97.   |   +--------------+ +-+  +----+-+-+--+<-- Gadgets
  98.   | B |#             | |0|  |COPY| |UNDO| |
  99.   |   +--------------+ +-+  +----+ +----+ |
  100.   | +-+-+-+-+-+-+-+-+      +---+ +------+ |
  101.   | | | | | | | | | |      |ADD| |DELETE|<-- Special Copper
  102.   | +-+-+-+-+-+-+-+-+      +---+ +------+ |  gadgets
  103.   |        ^                              |
  104.   +--------|------------------------------+
  105.            |
  106.            Colour registers
  107.  
  108. As you notice it looks rather similar to normal "Colour
  109. Requesters", but this one is much more powerful and fun to
  110. use.
  111.  
  112.  
  113.  
  114. 3.1 THE NORMAL COLOURS
  115.  
  116. One of the advantages with CopperDraw is that you can both
  117. create copper lists and edit the colours as normal. To use
  118. it as a normal colour requester does not differ much from
  119. other colour requesters. If you look at the window just above
  120. the gadgets you will see the text "COLOUR". As long as this
  121. text is there the program will work as any other colour
  122. requester.
  123.  
  124. If you start to edit the copper list the text will be changed,
  125. and you will see the word "COPPER". When you are editing the
  126. copper list the requester will work differently as will be
  127. described in the next section.
  128.  
  129.  
  130.  
  131. 3.1.1  SELECT COLOUR
  132.  
  133. When you start CopperDraw you can set the number of colour
  134. registers that should be used. The available colour registers
  135. will be listed below the colour sliders. Each colour register
  136. is represented with filled box. The more bitplanes you are
  137. using the more available colour registers:
  138.  
  139.   Bitplanes   Colour Registers
  140.   ----------------------------
  141.       1              2
  142.       2              4
  143.       3              8
  144.       4             16
  145.       5             32
  146.  
  147. To select one of the colour registers simply move the mouse
  148. pointer to one of the boxes and press the left mouse button.
  149. The colour will be selected (a small box is drawn around it),
  150. and the colour sliders are automatically adjusted.
  151.  
  152.  
  153.  
  154. 3.1.2  CHANGE COLOUR
  155.  
  156. Once you have selected a colour register you can start to
  157. alter its colour. By moving the buttons inside the colour
  158. sliders the colour is automatically changed. The further to
  159. the right the buttons are moved the brighter colour. The first
  160. slider adjusts the red intensity, the second slider the green
  161. intensity and the third slider the blue intensity.
  162.  
  163.  
  164.  
  165. 3.1.3  COPY COLOUR
  166.  
  167. To copy the current colour to another register click on the
  168. "Copy" gadget. The mouse pointer should now contain the text
  169. "to". Now move the pointer to the colour register you want to
  170. copy the colour to, and click once on the left button. The
  171. colour is copied, and this colour register will be selected.
  172.  
  173.  
  174.  
  175. 3.1.4  EXCHANGE COLOURS
  176.  
  177. To exchange the colours from one colour register with another
  178. colour register click on the "Ex" gadget. Move the mouse
  179. pointer to the colour register you want to change colour with,
  180. and press the left mouse button. The colours are exchanged,
  181. and this colour register will be selected.
  182.  
  183.  
  184.  
  185. 3.1.5  SPREAD
  186.  
  187. One nice feature is that you can spread a colour from one
  188. colour register to another colour register. The colour
  189. registers between will be changed so the colour is smoothly
  190. altered from the first colour register to the second colour
  191. register. This is very useful when you want to create shadows
  192. etc.
  193.  
  194.  
  195.  
  196. 3.1.6  UNDO
  197.  
  198. We are all humans (well, most of us at least) and we do make
  199. mistakes. Luckily you do not have to worry about this since
  200. you can always press the "Undo" gadget, and the colours will be
  201. restored to the values they had before the last operation. 
  202.  
  203.  
  204.  
  205. 3.2 COPPER INSTRUCTIONS
  206.  
  207. Now the magic begins! There exist a special coprocessor inside
  208. Amiga computers that is called "Copper". The great thing with
  209. this processor is that it can alter the colour values of the
  210. colour registers as the display is drawn. One colour register
  211. can therefore display several colours.
  212.  
  213. What you have to do is to tell the Copper where on the display
  214. the colour value should be changed, and to what colour. In C
  215. you would use the CWAIT() and CMOVE() macros. Since the Copper
  216. is a coprocessor it will not slow down the main processor. You
  217. can use hundreds of different colours but still only use very
  218. few colour registers.
  219.  
  220. Normally is only the background colour (colour register 0)
  221. altered by the copper, but you can of course alter any colour
  222. registers you want. CopperDraw can alter all colour registers.
  223.  
  224.  
  225.  
  226. 3.2.1  ADD COPPER INSTRUCTION
  227.  
  228. If you want that the Copper should alter a colour, you have to
  229. add a copper instruction. To add an instruction press the "Add"
  230. gadget. The mouse pointer will change image, and the text
  231. "COLOUR" will be replaced with the text "COPPER".
  232.  
  233. Move the mouse pointer outside the window to the (vertical)
  234. location where the colour should be changed, and press the left
  235. mouse button. A special pointer in the left margin will appear
  236. telling you where the instruction was placed. If you now start
  237. to move the buttons inside the colour sliders you will notice
  238. that you are changing the colour below the line you place the
  239. copper instruction.
  240.  
  241. You can place as many copper instructions as you want!
  242.  
  243.  
  244.  
  245. 3.2.2  SELECT COPPER INSTRUCTION
  246.  
  247. If you want to change a copper colour you have previously set,
  248. you simply move the mouse pointer to the line you want to
  249. change and press the left mouse button. You will notice that
  250. the left pointer is moved to the new location, and the colour
  251. sliders are automatically adjusted appropriately. You can now
  252. alter the colour.
  253.  
  254. You do actually not need to point exactly on the line to select
  255. a copper colour. CopperDraw will select the first copper colour
  256. which is above the mouse pointer. To select a colour you simply
  257. point on the correct line or any line below it until the next
  258. copper colour.
  259.  
  260. You can always look at the small copper cursor in the left
  261. margin to see which copper colour (line/instruction) is
  262. currently selected. If you can not see the copper cursor, no
  263. line is selected.
  264.  
  265.  
  266.  
  267. 3.2.3  DELETE COPPER INSTRUCTION
  268.  
  269. To delete a copper colour you press the "Delete" gadget and
  270. move the mouse pointer to the copper colour (line/instruction)
  271. you want to delete. Press the left mouse button to remove the
  272. it. (The first copper instruction/colour just above the mouse
  273. pointer will be removed.)
  274.  
  275.  
  276.  
  277. 3.2.4  COPY COPPER INSTRUCTION
  278.  
  279. If one of the copper colours is selected you can copy it to
  280. another (previously set) copper colour. Press on the "Copy"
  281. gadget and move the mouse pointer to the copper colour you
  282. want the current colour to be copied to, and press the left
  283. mouse button. The colour will be copied, and the destination
  284. copper colour will be selected.
  285.  
  286. Note that the text "COPPER" must be on. If it says "COLOUR"
  287. you have not selected a copper instructions, which you must
  288. do first.
  289.  
  290.  
  291.  
  292. 3.2.5  EXCHANGE COPPER INSTRUCTIONS
  293.  
  294. To exchange one copper colour with another you press on the
  295. "Ex" gadget, move the mouse pointer to the destination copper
  296. colour, and click on the left mouse button. The copper colours
  297. will be exchanged, and the destination colour will be selected.
  298.  
  299.  
  300.  
  301. 3.2.6  SPREAD
  302.  
  303. This is probably the most useful feature with CopperDraw.
  304. Select a copper instruction, press the "Spread" gadget, and
  305. finally select a destination copper colour. CopperDraw will now
  306. automatically generate as many new copper instructions as
  307. necessary to make a smooth transition between the two colours.
  308. With this function you can within seconds create smooth
  309. coloured skies and spectacular colour compositions!
  310.  
  311. Let me demonstrate this with an example. Add a copper colour at
  312. the bottom of the screen. Change the colour to black. Add
  313. another copper colour somewhere on the middle of the screen.
  314. Change it to bright red. Click on the "Spread" gadget and move
  315. the mouse pointer to the bottom of the screen, and press the
  316. left mouse button. CopperDraw will immediately create 14 new
  317. copper instructions and set the colours so you get a smooth
  318. transition from the red colour to the black!
  319.  
  320.  
  321.  
  322. 3.3  SWITCH BETWEEN COLOUR REGISTERS
  323.  
  324. Although the background colour (colour register 0) is often
  325. only used, you can alter any of the colour registers. If you
  326. want to alter the colours of another colour register you simply
  327. move the mouse to one of the coloured boxes and click on the
  328. left mouse button. CopperDraw will now automatically fill the
  329. whole display (except the border were only the background
  330. colour can be used) with the selected colour.
  331.  
  332. If you now add copper instructions you will affect the colours
  333. of the selected colour register. You can use up to 32 different
  334. colour registers (5 bitplanes), and each colour register can
  335. have its own copper colours!
  336.  
  337.  
  338.  
  339. 3.3.1  DISPLAY ALL COLOUR REGISTERS
  340.  
  341. It can sometimes be necessary to see all colour registers at
  342. the same time. If you press key "F9", CopperDraw will fill the
  343. screen with a rectangle for each colour register. You can now
  344. as before add and alter the copper colours.
  345.  
  346. Note that you will only alter the selected colour register,
  347. and if you want to alter another colour register you have to
  348. select it first. The copper cursor which previously always was
  349. located on the left margin will now move horizontally to the
  350. current colour register and vertically to the current copper
  351. instruction.
  352.  
  353.  
  354.  
  355. 3.3.1  DISPLAY CURRENT COLOUR REGISTER
  356.  
  357. To remove the rectangles and use the current colour register
  358. as before, press "F10".
  359.  
  360.  
  361.  
  362. 3.4  REMOVE THE WINDOW
  363.  
  364. If you want to see the while display without being disturbed by
  365. the window you can press on the "delete" key ("Del" is placed
  366. on the left side of the "Help" key). The window will immediately
  367. disappear. If you press on any key the window will become
  368. visible again. 
  369.  
  370.  
  371.  
  372. 3.5  QUIT
  373.  
  374. Once you have created your copper list you should quit. Press
  375. on the close window gadget (top left corder of the window), and
  376. the program will save the current copper list in C code, and
  377. then terminates. The copper file can then easily be included
  378. in your own programs, and you will then almost directly have a
  379. Mega Demo! (Well at least a nice copper list.)
  380.  
  381.  
  382.  
  383. 4.0  IMPORT THE COPPER CODE IN YOUR OWN PROGRAMS
  384.  
  385. Once you have created a nice copper list you quit and the list
  386. will automatically be converted to C code and saved. This code
  387. can then easily be included in your own programs.
  388.  
  389.  
  390.  
  391. 4.1  COPPER FILE
  392.  
  393. A short copper list for a two coloured screen with only four
  394. copper colours would look something like this:
  395.  
  396. /***************************************/
  397. /*                                     */
  398. /* Copper List made by CopperDraw V1.0 */
  399. /* Amiga C Encyclopedia, Anders Bjerin */
  400. /*                                     */
  401. /***************************************/
  402.  
  403. /* The copper list: */
  404. CINIT( copper, 1 );
  405. CWAIT( copper, 62, 0 );
  406.   CMOVE( copper, custom.color[0], 0x0F00 );
  407. CWAIT( copper, 134, 0 );
  408.   CMOVE( copper, custom.color[0], 0x00F0 );
  409.   CMOVE( copper, custom.color[1], 0x000F );
  410. CWAIT( copper, 182, 0 );
  411.   CMOVE( copper, custom.color[0], 0x0FF0 );
  412. CEND( copper );
  413.  
  414. /* The Colour Table: */
  415. UWORD my_color_table[]=
  416. {
  417.   0x666, /* Colour  0 */
  418.   0xFFF  /* Colour  1 */
  419. };
  420.  
  421. As you can see will CopperDraw both create a copper list and
  422. a colour table. Note that line 134 there exist two copper
  423. colours. Both colour register 0 and 1 are altered, but since
  424. they are on the same line only one CWAIT() call is done.
  425.  
  426.  
  427.  
  428. 4.2  HOW TO USE THE COPPER LIST
  429.  
  430. To use a copper list you only have to follow these steps:
  431.  
  432.   1. Declare a Custom structure called "custom". This
  433.      structure will automatically be initialized by the Amiga.
  434.      Note that on most compilers it has to be declared
  435.      together with a "far" statement. (The Custom structure
  436.      is usually placed far away from you code, and to reach
  437.      it you have to use "far" pointers.
  438.  
  439.        extern struct Custom far custom;
  440.  
  441.  
  442.   2. Declare a pointer to a copper list structure. It should
  443.      have the same name as the "copper name" argument you used
  444.      when you started CopperDraw. The default name is "copper",
  445.      and should be used if you did not give it some other name.
  446.  
  447.        struct UCopList *copper;
  448.  
  449.  
  450.   3. Allocate some chip memory for a UCopList structure. If it
  451.      is not chip memory the Copper can not reach it, and your
  452.      copper list will not work. The memory should also be made
  453.      "public" so other parts of the Amiga may use it.
  454.      
  455.      This structure will later be connected to a ViewPort, and
  456.      the ViewPort will automatically deallocated the UCopList
  457.      structure when you close the ViewPort. We should therefore
  458.      not deallocate it ourself as might be expected.
  459.      
  460.      Remember to always check if you received the memory!
  461.  
  462.        copper = (struct UCopList *)
  463.            AllocMem( sizeof(struct UCopList),
  464.                    MEMF_PUBLIC|MEMF_CHIP|MEMF_CLEAR );
  465.  
  466.        if( !copper )
  467.          clean_up( "Not enough memory!" );
  468.  
  469.  
  470.   4. You should now open your own screen or create your own
  471.      display. See chapter "LowLevelGraphics" for more
  472.      information about displays.
  473.  
  474.  
  475.   5. After the display has been prepared you execute the copper
  476.      list. Remember that you must always start with a CINIT()
  477.      call, and finish off with a CEND() call.
  478.  
  479.        CINIT( copper, 1 );
  480.        CWAIT( copper, 62, 0 );
  481.          CMOVE( copper, custom.color[0], 0x0F00 );
  482.  
  483.        /* ... */
  484.  
  485.        CEND( copper );
  486.  
  487.   6. You should now link the UCopList memory to the ViewPort.
  488.      If you have created your own display you already have
  489.      a ViewPort structure. If on the other hand is using a
  490.      screen under Intuition, you can find the ViewPort
  491.      structure in the "ViewPort" field of the Screen structure.
  492.  
  493.        my_view_port = &(my_screen->ViewPort);
  494.  
  495.  
  496.      Once you have the address to the view port you give the
  497.      UCopIns field of it the address to your own copper list.
  498.      ("my_view_port" is a ViewPort structure.)
  499.  
  500.        my_view_port.UCopIns = copper;
  501.  
  502.  
  503.   7. You can now tell the Amiga to generate its own copper
  504.      list with help of yours. You do it by calling the
  505.      MakeVPort() function. This ViewPort's copper list
  506.      should then be merged together with the others ViewPort's
  507.      copper list by calling the MrgCop() function. Finally you
  508.      call the LoadView() function to let the user see your
  509.      new display and copper list. ("my_view" is a View
  510.      structure)
  511.  
  512.        MakeVPort( &my_view, &my_view_port );
  513.        MrgCop( &my_view );
  514.        LoadView( &my_view );
  515.  
  516.      If you have opened a Screen under Intuition you should
  517.      not use low level functions like MrgCop(). Instead you
  518.      should call the RethinkDisplay() function which will
  519.      automatically create the display for you.
  520.  
  521.        RethinkDisplay();
  522.  
  523.  
  524.   8. If you have created the display yourself you should call
  525.      the FreeVPortCopLists() and FreeCprList() functions when
  526.      you want to close the display. They will automatically
  527.      remove and deallocate all copper lists for you.
  528.  
  529.        FreeVPortCopLists( &my_view_port );
  530.        FreeCprList( my_view.LOFCprList );
  531.      
  532.      If you have opened a screen under Intuition this will be
  533.      done automatically when you close the screen.
  534.  
  535.  
  536.  
  537. 4.3  EXAMPLE
  538.  
  539. See the examples in the "Copper" chapter. 
  540.  
  541.  
  542.  
  543.  
  544. 5.0  BASIC, ASSEMBLER AND PASCAL PROGRAMMERS
  545.  
  546. The code generated by CopperDraw can easily be included in
  547. your own C programs, but can also easily be included in your
  548. own Basic, Assembler or Pascal programs too. You may have to
  549. rename some of the macros, but it should not be difficult.
  550.  
  551. Please note that I am a C programmer and can hardly add 1 + 1
  552. in Assembler, and is not familiar with Basic nor Pascal on the
  553. Amiga. I can therefore not help you with any questions you
  554. might have about how to create copper lists. Try to find some
  555. friends or a user group that can help you.
  556.  
  557. To all Amiga Programmers, have FUN!!!
  558.  
  559.  
  560. NOTE! This is a non registered version, and no copper list file
  561. will therefore be created! To get the complete version simply
  562. register your copy.
  563.  
  564. The registration fee is only £30, $60, SEK 300, or similar
  565. amount in your own currency (price includes everything). The
  566. Amiga C Encyclopedia is the largest collection of documents,
  567. examples and utilities in C for the Amiga and it is still among
  568. the cheapest manuals. But this is not all, a registered owner
  569. will also get:
  570.  
  571.   1. Two disks containing the last parts of the encyclopedia.
  572.      The disks will be sent by first class air mail.
  573.  
  574.   2. Registration card for the Amiga C Club (ACC).
  575.  
  576.   3. Immediate information about updates.
  577.  
  578.   4. Updated versions of the encyclopedia for only the cost of
  579.      disks plus postage and packing.
  580.  
  581.   5. Assistance with digitizing colour pictures and sampling
  582.      sound effects.
  583.  
  584.   6. Unlimited help with your C programs. You never have to be
  585.      alone with your problems.
  586.  
  587.   7. The right to use parts of the manual in your own
  588.      commercial/non-commercial programs/articles.
  589.  
  590. Can any other manual give you all this???
  591.  
  592. The simplest way of paying is to include the money in a letter
  593. in cash. US dollar bills, English pounds or Swedish SEK are
  594. preferred, but all currencies are accepted. You can also send
  595. the money as a "Postal Money Order", ask your local bank or
  596. post office. Please do not use cheques. It is sadly extremely
  597. expensive to cash a foreign cheque here in Sweden.
  598.  
  599. If you live in Scandinavia you can send the money to "Svenska
  600. Post Girot, postgiro konto: 641 88 30 - 3, betalnings-
  601. mottagare: Datra".
  602.  
  603. Please send the registration fee together with your complete
  604. address to:
  605.  
  606.   Datra, Amiga C Club
  607.   Anders Bjeri
  608.   Tulevagen 22
  609.   181 41  LIDINGO
  610.   SWEDEN
  611.  
  612. I have worked for more than four years now with this
  613. encyclopedia, and with your help I can continue to improve it.
  614.  
  615. Happy programming!!!
  616.